//
//  TitleView.m
//  LoveFreshBeen
//
//  Created by Cyan on 2016/10/21.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "TitleView.h"

#import "AdressTableViewController.h"
#import "MyAdressModel.h"
@interface TitleView ()



@end


@implementation TitleView

- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeAddres:) name:@"address" object:nil];
}


- (void)changeAddres:(NSNotification *)notification {
    
    
    MyAdressModel *model = notification.object;
    

    NSString *string = model.address.copy;
    
    NSRange range = [string rangeOfString:@" "];

    string = [string substringToIndex:range.location];
    
    NSLog(@"- %@在%@ -",model.accept_name,string);
    
    [self.address setTitle:string forState:UIControlStateNormal];
    
}

- (IBAction)addressButtnClick:(UIButton *)sender {
    
    
    AdressTableViewController *vc = [[AdressTableViewController alloc] init];
    vc.type = 1;
    [[self viewController] pushViewController:vc animated:YES];
    
}



- (UINavigationController *)viewController
{
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UINavigationController class]]) {
            return (UINavigationController *)nextResponder;
        }
    }
    return nil;
}


@end
